﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CSharpDay03__polymorphism_
{
    public class Program
    {
        public static void Main(string[] args)
        {
            List<Dog> dogList = new List<Dog>(); //list used to hold all of our dogs
            bool repeat = true; //when repeat is set to false, exit the program
            do
            {
                //Prompts the user for Name, Age, and Breed to create our dog object
                Console.Write("Please enter a name for the dog: ");
                string inputName = Console.ReadLine();
                Console.Write("Please enter an age: ");
                string goldfish = Console.ReadLine();
                Console.Write("Please enter a breed: ");
                string apple = Console.ReadLine();

                //Creates a new dog object, and adds it to our list
                Dog dog = new Dog()
                {
                    Name = inputName,
                    Age = Int32.Parse(goldfish),
                    Breed = apple
                };
                dogList.Add(dog);

                DisplayDogs(dogList);

                //Used to exit the program
                Console.WriteLine("-----------------------------------------------");
                Console.Write("Would you like to continue? (y/n)");
                string result = Console.ReadLine();
                if (result.ToLower()[0] == 'n') repeat = false;
            } while (repeat == true);

            }
        public static void DisplayDogs(List<Dog> dogs)
        {
            Console.WriteLine("-------------------------------------");
            foreach (Dog apple in dogs)
            {
                Console.WriteLine("Dog {0} is {1} years old, and is a {2}.", apple.Name, apple.Age, apple.Breed);
            }
            /*
             * for(var i = 0; i < dogs.length; i++) {
             *  var d = dogs[i];
             * }
             */

            List<Cat> catList = new List<Cat>(); //list used to hold all of our cats
            bool repeat = true; //when repeat is set to false, exit the program
            do
            {
                //Prompts the user for Name, Age, and Breed to create our dog object
                Console.Write("Please enter a name for the cat: ");
                string inputName = Console.ReadLine();
                Console.Write("Please enter an age: ");
                string goldfish = Console.ReadLine();
                Console.Write("Please enter a breed: ");
                string apple = Console.ReadLine();

                //Creates a new dog object, and adds it to our list
                Cat cat = new Cat()
                {
                    Name = inputName,
                    Age = Int32.Parse(goldfish),
                    Type = apple
                };
                catList.Add(cat);

                DisplayCats(catList);

                //Used to exit the program
                Console.WriteLine("-----------------------------------------------");
                Console.Write("Would you like to continue? (y/n)");
                string result = Console.ReadLine();
                if (result.ToLower()[0] == 'n') repeat = false;
            } while (repeat == true);
        }

        public static void DisplayCats(List<Cat> cats)
        {
            Console.WriteLine("-------------------------------------");
            foreach (Cat apple in cats)
            {
                Console.WriteLine("Cat {0} is {1} years old, and is a {2}.", apple.Name, apple.Age, apple.Type);
            }

        }
    }
}

public class Animal
{
    public string Name { get; set; }
    public int Age { get; set; }
}

public class Dog : Animal
{
    public string Breed { get; set; }
}

public class Cat : Animal
{
    public string Type { get; set; }
}

